
  <template>
  <div class="bf-commont-template">
    <!-- <div style="padding: 0 16px ;">
      <h3>面试管理</h3>
      <p>该页面代码已经自动生成，按照普通码 表增删改查 为基础生成模板</p>
      <p>生成代码对应的 vue 文件路径：D:\Zmyitem\vue-element-admin\src\beneform4j\view\hr\recruit\planaudit\index.vue</p>
      <el-alert title="注意：表格内数据为模拟数据, 如果数据格式不对，请先进行格式转换。 模拟数据文件路径：src/mock/demo.js" type="warning"> </el-alert>
    </div> -->

    <div class="clearfix bf-top-button">
      <div class="float-l">
        <el-button @click="showAdd" type="primary">新增候选人</el-button>
      </div>
      <div class="float-r">
        <div class="float-l">
          <el-input placeholder="请输入姓名搜索内容" prefix-icon="el-icon-search" v-model="searchData" @keyup.enter.native="quickSearch"></el-input>
        </div>
        <div class="float-l padding-l">
          <el-button @click="showSearch" type="primary">高级筛选</el-button>
        </div>
      </div>
    </div>
    <el-tabs v-model="activeName" @tab-click="handleClick" class="margin-l margin-r">
      <el-tab-pane :label="'新候选'+ tabs.primaryCount+'人'" status="1" name="candidate">
        <bf-table :data="waitVettData" :setting="CandidateSetting" :rowAction="CandidaterowAction" @pageChange="pageChange" @editSubmit="editSubmit" :editRules="editRules" ref="primaryTable"></bf-table>
      </el-tab-pane>

      <el-tab-pane :label="'初选通过'+ tabs.primaryPassCount+'人'" status="2" name="primary">
        <bf-table :data="waitVettData" :setting="CandidateSetting" :rowAction="primaryrowAction" @pageChange="pageChange" :editRules="editRules" ref="table"></bf-table>
      </el-tab-pane>

      <el-tab-pane :label="'待面试'+ tabs.interviewCount+'人'" status="3" name="interview">
        <bf-table :data="waitVettData" :setting="CandidateSetting" :rowAction="interviewRowAction" @pageChange="pageChange" :editRules="editRules" ref="table"></bf-table>
      </el-tab-pane>

      <el-tab-pane :label="'面试通过'+ tabs.interviewPassCount+'人'" status="5" name="interviewPass">
        <bf-table :data="waitVettData" :setting="passInterviesSetting" :rowAction="interviewPassRowAction" @pageChange="pageChange" :editRules="editRules" ref="table"></bf-table>
      </el-tab-pane>

      <el-tab-pane :label="'offer审批'+ tabs.offerApproveCount+'人'" status="6" name="offerApprove">
        <bf-table :data="waitVettData" :setting="passInterviesSetting" :rowAction="offerApproveRowAction" @pageChange="pageChange" :editRules="editRules" ref="table"></bf-table>
      </el-tab-pane>

      <el-tab-pane :label="'offer反馈'+ tabs.offerRecuperativeCount+'人'" status="7" name="offerFeedBack">
        <bf-table :data="waitVettData" :setting="passInterviesSetting" :rowAction="offerFeedBackRowAction" @pageChange="pageChange" :editRules="editRules" ref="table"></bf-table>
      </el-tab-pane>
    </el-tabs>
    <!-- 添加候选人 -->
    <bf-table-add :width="800" :rowNum="2" :editForm='addSetting' :title="'添加候选人'" ref='addRosterRef' @formSubmit='addRosterSubmit' :editRules="addRules"></bf-table-add>
    <!--高级搜索 -->
    <bf-table-search :editForm='searchSetting' :title="'高级搜索'" ref='searchRosterRef' @formSubmit='searchRosterSubmit'></bf-table-search>
    <!-- 编辑 -->
    <bf-table-edit :width="800" :rowNum="2" :editForm='editSetting' :title="'编辑'" ref='convertFullRosterRef' @formSubmit='convertFullRosterSubmit' :editRules="addRules"></bf-table-edit>
    <!-- 安排面试 -->
    <bf-table-edit :editForm='interviesEditSetting' :title="'安排面试'" ref='interviesEditRosterRef' @formSubmit='interviewRosterSubmit' :editRules="interViewRules"></bf-table-edit>
    <!-- 淘汰流失原因 -->
    <bf-table-edit :editForm='eliminationSetting' :title="'淘汰流失'" ref='eliminationRosterRef' @formSubmit='eliminationRosterSubmit' :editRules="eliminationRules"></bf-table-edit>
    <!-- 移动到面试通过 -->
    <bf-table-edit :width="550" :editForm='removeInterviewPassSetting' :title="'填写面试结果'" ref='removeInterviewPassRosterRef' @formSubmit='removeInterviewPassSubmit' :editRules="removeInterviewPassRules"></bf-table-edit>
    <!-- offer发送申请-->
    <bf-table-edit :width="800" :rowNum="2" :editForm='offerSendSetting' :title="'offer发送申请'" ref='offerSendRosterRef' @formSubmit='offerSendRosterSubmit' :editRules="offerSendRules"></bf-table-edit>
    <!-- 审批通过-->
    <bf-table-edit :width="800" :rowNum="2" :editForm='offerSendSetting' :title="'审批'" ref='approveRosterRef' @formSubmit='offerSendApproveSubmit' :editRules="offerSendRules"></bf-table-edit>

    <!-- 发送offer放弃-->
    <bf-table-edit :editForm='sendOfferSetting' :title="'发送offer'" ref='sendOfferRosterRef' @formSubmit='sendOfferRosterSubmit' :editRules="eliminationRules"></bf-table-edit>
    <!-- offer审批中的其他情况-->
    <bf-table-edit :width="800" :rowNum="2" :editForm='giveUpOfferSetting' :title="'编辑'" ref='giveUpOfferRosterRef' @formSubmit='giveUpOfferSubmit' :editRules="giveUpOfferRules"></bf-table-edit>
    <!--详情-->
    <bf-table-detail
      :width="800"
      :rowNum="2"
      ref="bfTableDetail"
      :title="'面试详情'"
      :editForm="addSetting"
      :showInterHis="true"
      ></bf-table-detail>
    <!--审批-->
    <bf-table-edit :width="800" :rowNum="2" :editForm='approveSetting' :title="'offer审批'" :submitButtons="submitButtons" ref='approveRef' @formSubmit='sendOfferRosterSubmit' :editRules="approveRules"></bf-table-edit>

    <!-- 反馈通过-->
    <!-- <bf-table-detail :width="800" :rowNum="2" :editForm='feedbackYesSetting' ref='feedbackYesDetailRef'></bf-table-detail> -->
    <!-- 反馈通过-->
    <bf-table-edit :title="'接受offer'" :width="800" :rowNum="2" :editForm='feedbackYesSetting' ref='feedbackYesRef' @formSubmit='feedbackYesSubmit' :editRules="offerSendRules"></bf-table-edit>
    <!--反馈不通过-->
    <!-- <bf-table-detail  :width="800" :rowNum="2" ref="feedbackNoDetailRef" :editForm="feedbackNoSetting"></bf-table-detail> -->
    <!--反馈不通过-->
    <bf-table-edit :title="'放弃offer'" :width="800" :rowNum="2" :editForm='feedbackNoSetting' ref='feedbackNoRef' @formSubmit='feedbackNoSubmit' :editRules="eliminationRules"></bf-table-edit>

    <!--feedbackYesSetting ,feedbackNoSetting-->
  </div>
</template>

<script>
import { searchSetting, CandidateSetting, passInterviesSetting, approveSetting, addSetting, interviesEditSetting, eliminationSetting, offerSendSetting, sendOfferSetting, editSetting, removeInterviewPassSetting, giveUpOfferSetting, feedbackNoSetting, feedbackYesSetting } from './table.setting.js'
import { getPlanaudit, updateInterviewer, findDetail, getRequireList, findProcessDetail, deleteInterview, updateStatus, eliminate, offerSendApply, addInterview, arrangeInterview, passInterviewer, feedBackOffer, immediateInterviewer, waitInterviewer } from './api.js'
export default {
  data() {
    return {
      searchSetting: searchSetting,
      searchData: '',
      userData: {
      },
      detailData: {},
      waitVettData: {},
      vettedData: {},
      statusData: {},
      submitButtons: [

        {
          title: '通过',
          click: (form) => {
            delete form.docList
            form.approvalFlag = 1
            this.offerSendApproveSubmit(form)
          }
        },
        {
          title: '不通过',
          click: (form) => {
            delete form.docList
            form.approvalFlag = 0
            this.offerSendApproveSubmit(form)
          }
        },
        {
          title: '取消',
          click: (form) => {
            this.$refs.approveRef.hiden()
          }
        }
      ],
      tabs: {
        primaryCount: 0,
        primaryPassCount: 0,
        interviewCount: 0,
        interviewPassCount: 0,
        offerApproveCount: 0,
        offerRecuperativeCount: 0
      },
      activeName: 'candidate',
      CandidaterowAction: [ // 新候选
        {
          label: '详情',
          click: (item) => {
            this.findInterviewDetail(item.scope.row.intvId, this.$refs.bfTableDetail.show)
          }
        },
        {
          label: '移动到初选通过',
          click: (item) => {
            // this.$refs.primaryTable.showDetail(item)
            this.moveingPrimaryPass(item);
          }
        },

        {
          label: '编辑',
          click: (item) => {
            this.findInterviewDetail(item.scope.row.intvId, this.$refs.convertFullRosterRef.show)
          }
        },
        {
          label: '淘汰/流失',
          click: (item) => {
            item.scope.row.remarks = ''
            item.scope.row.paramsName = 'xhx'
            this.$refs.eliminationRosterRef.show(item.scope)
          }
        },
        {
          label: '删除',
          click: (item) => {
            this.$refs.primaryTable.showDelete(item)
          }
        }
      ],
      primaryrowAction: [ // 初选通过
        {
          label: '详情',
          click: (item) => {
            this.findInterviewDetail(item.scope.row.intvId, this.$refs.bfTableDetail.show)
          }
        },

        {
          label: '安排面试',
          click: (item) => {
            this.$refs.interviesEditRosterRef.show(item.scope)
          }
        },
        {
          label: '移动到候选人',
          click: (item) => {
            this.moveingPrimary(item);
          }
        },
        {
          label: '淘汰/流失',
          click: (item) => {
            item.scope.row.paramsName = 'cxtg'
            item.scope.row.remarks = ''
            this.$refs.eliminationRosterRef.show(item.scope)
          }
        }

      ],
      interviewRowAction: [ // 面试
        {
          label: '详情',
          click: (item) => {
            this.findInterviewDetail(item.scope.row.intvId, this.$refs.bfTableDetail.show)
          }
        },
        {
          label: '填写面试结果',
          click: (item) => {
            //
            this.findInterviewPassDetail(item.scope.row.intvId, this.$refs.removeInterviewPassRosterRef.show)
            // this.$refs.removeInterviewPassRosterRef.show(item.scope)
          }
        },

        {
          label: '淘汰/流失',
          click: (item) => {
            item.scope.row.paramsName = 'dms'
            this.$refs.eliminationRosterRef.show(item.scope)
          }
        }
        // {
        //   label: '下载简历',
        //   click: (item) => {
        //     this.$refs.table.showDelete(item)
        //   }
        // }
      ],
      interviewPassRowAction: [ // 面试通过
        // {
        //   label: '移动到候选人',
        //   click: (item) => {
        //     if (item.scope.row.status !== '4') {
        //       this.moveingPrimary(item)
        //     } else {
        //       this.$message({
        //         message: '等待面试不可移动到候选人',
        //         type: 'error'
        //       })
        //       return false
        //     }
        //   }
        // },
        // {
        //   label: '移动到初选通过',
        //   click: (item) => {
        //     if (item.scope.row.status !== '4') {
        //       this.moveingPrimaryPass(item)
        //     } else {
        //       this.$message({
        //         message: '等待面试不可移动到初选通过',
        //         type: 'error'
        //       })
        //       return false
        //     }
        //   }
        // },
        {
          label: '详情',
          click: (item) => {
            this.findInterviewDetail(item.scope.row.intvId, this.$refs.bfTableDetail.show)
          }
        },
        {
          label: 'offer发出申请',
          click: (item) => {
            if (item.scope.row.status !== '4') {
              this.findInterviewDetailOff(item.scope.row.intvId, this.$refs.offerSendRosterRef.show)
            } else {
              this.$message({
                message: '等待面试不可offer发出申请',
                type: 'error'
              })
              return false
            }
          }
        },
        {
          label: '重新安排复试',
          click: (item) => {
            this.findInterviewDetail(item.scope.row.intvId, this.$refs.interviesEditRosterRef.show)
          }
        },

        // {
        //   label: '下载简历',
        //   click: (item) => {
        //     this.$refs.table.showDelete(item)
        //   }
        // }
      ],

      offerApproveRowAction: [
        {
          label: '详情',
          click: (item) => {
            this.findInterviewDetail(item.scope.row.intvId, this.$refs.bfTableDetail.show)
          }
        },
        {
          label: '审批',
          click: (item) => {
            this.findInterviewDetail(item.scope.row.intvId, this.$refs.approveRef.show)
          }
        }

      ],
      offerFeedBackRowAction: [
        {
          label: '详情',
          click: (item) => {
            this.findInterviewDetail(item.scope.row.intvId, this.$refs.bfTableDetail.show)
          }
        },
        {
          label: '接受',
          click: (item) => {
            this.findInterviewDetail(item.scope.row.intvId, this.$refs.feedbackYesRef.show)
          }
        },
        {
          label: '放弃',
          click: (item) => {
            this.findInterviewDetail(item.scope.row.intvId, this.$refs.feedbackNoRef.show)
          }
        }

      ],
      CandidateSetting: CandidateSetting,
      passInterviesSetting: passInterviesSetting,
      editSetting: editSetting, // 编辑候选人
      addSetting: addSetting, // 新增候选人
      interviesEditSetting: interviesEditSetting, // 面试的编辑set
      eliminationSetting: eliminationSetting, // 淘汰流失原因
      removeInterviewPassSetting: removeInterviewPassSetting, // 移动到面试通过
      offerSendSetting: offerSendSetting, // offer发送申请
      sendOfferSetting: sendOfferSetting, // 发送offer、放弃
      giveUpOfferSetting: giveUpOfferSetting, // offer审批的其他情况
      approveSetting: approveSetting, // 审批
      feedbackNoSetting: feedbackNoSetting, // 反馈不通过

      feedbackYesSetting: feedbackYesSetting, // 反馈通过
      addRules: { // 新增，编辑验证
        reqId: [
          { required: true, message: '请选择招聘需求', trigger: 'blur' }
        ],
        intvName: [
          { required: true, message: '请输入姓名', trigger: 'blur' },
          { min: 2, max: 50, message: '长度在 2 到 50个字符', trigger: 'blur' }
        ],
        mobile: [
          { required: true, message: '请输入手机号', trigger: 'blur' },
          { max: 15, message: '长度在 0 到15个字符', trigger: 'blur' }
          // { pattern: /1[0-9]{10}$+/, message: '输入字符只能为数字', trigger: 'blur' }
        ],
        email: [
          { required: true, message: '请输入邮箱', trigger: 'blur' },
          { min: 2, max: 200, message: '长度在 2 到30个字符', trigger: 'blur' }

        ],
        education: [
          { required: true, message: '请输入学历', trigger: 'blur' }
        ],
        remarks: [
          { max: 200, message: '长度在 0 到200个字符', trigger: 'blur' }
        ],
        graduationSchool: [
          { required: true, message: '请输入毕业学校', trigger: 'blur' }
        ],
        sex: [
          { required: true, message: '请输入年龄', trigger: 'blur' }
        ]
      },
      interViewRules: { // 面试
        appointmentInterviewer: [
          { required: true, message: '请选择面试官', trigger: 'blur' }
        ],
        appointmentInterviewDate: [
          { required: true, message: '请选择面试日期', trigger: 'blur' }
        ],
        appointmentInterviewTime: [
          { required: true, message: '请选择面试日期', trigger: 'blur' }
        ],
        appointmentInterviewAddr: [
          { required: true, message: '请输入面试地点', trigger: 'blur' },
          { min: 2, max: 100, message: '长度在 2 到 100个字符', trigger: 'blur' }
        ]
      },
      eliminationRules: { // 淘汰流失原因
        eliminationReason: [
          { required: true, message: '请输入淘汰流失原因', trigger: 'blur' }
        ],
        eliminationType: [
          { required: true, message: '请选择淘汰类型', trigger: 'blur' }
        ],
        remarks: [
          { min: 2, max: 200, message: '长度在 2到 200个字符', trigger: 'blur' }
        ]
      },

      approveRules: { // 淘汰流失原因
        remarks: [
          { required: true, message: '请输入面试地点', trigger: 'blur' },
          { min: 2, max: 200, message: '长度在 2到 200个字符', trigger: 'blur' }
        ]
      },
      removeInterviewPassRules: { // 移动到面试通过
        appointmentInterviewer: [
          { required: true, message: '请选择面试官', trigger: 'blur' }
        ],
        appointmentInterviewDate: [
          { required: true, message: '请选择面试日期', trigger: 'blur' }
        ],
        appointmentInterviewAddr: [
          { required: true, message: '请输入面试地点', trigger: 'blur' },
          { min: 2, max: 100, message: '长度在 2 到 100个字符', trigger: 'blur' }
        ],
        remarks: [
          { required: true, message: '请输入评语', trigger: 'blur' },
          { min: 2, max: 200, message: '长度在 2 到 200个字符', trigger: 'blur' }
        ],
        suggest: [
          { required: true, message: '请输入面试评语', trigger: 'blur' }
        ],
        appointmentInterviewer2: [
          { required: true, message: '请输入复试管', trigger: 'blur' }
        ]

      },
      giveUpOfferRules: { // offer审批的其他气矿
        remarks: [
          { required: true, message: '请输入评语', trigger: 'blur' },
          { min: 2, max: 200, message: '长度在 2 到 200个字符', trigger: 'blur' }
        ]
      },
      offerSendRules: {
        orgId: [
          { required: true, message: '请选择部门', trigger: 'blur' }
        ],
        position: [
          { required: true, message: '请选择岗位', trigger: 'blur' }
        ],
        postLevel: [
          { required: true, message: '请选择职级', trigger: 'blur' }
        ],
        workNature: [
          { required: true, message: '请选择工作性质', trigger: 'blur' }
        ],
        entryDate: [
          { required: true, message: '请选择预计入职日期', trigger: 'blur' }
        ]

      },
      editRules: { // 发送offer申请的验证
        name: [
          { required: true, message: '请输入用户名称', trigger: 'blur' },
          { min: 2, max: 20, message: '长度在 2 到 20个字符', trigger: 'blur' }
        ],
        roleName: [
          { required: true, message: '请输入用户角色', trigger: 'blur' },
          { min: 2, max: 20, message: '长度在 2 到 20个字符', trigger: 'blur' }
        ]
      },
      searchParams: { // 搜索条件
        page: 1
      }
    }
  },
  mounted: function() {
    this.getTabs()
    this.searchList('', '1')
  },
  methods: {
    addRosterSubmit(form) { // 添加候选人
      if (form.age && form.age.length>2) {
        this.$message({
          message: '年龄输入太长',
          type: 'error'
        })
        return false
      }
      addInterview(form).then((response) => {
        if (response.success) {
          this.$message({
            message: '新增成功',
            type: 'success'
          })
          this.$refs.addRosterRef.hiden();
          this.searchList('', this.getActivityStatus())
        }
      })
    },
    searchRosterSubmit(form) {
      this.searchParams.education = form.education
      this.searchParams.graduationSchool = form.graduationSchool
      this.searchParams.intvName = form.intvName
      this.searchParams.reqId = form.reqId

      this.searchList()
      this.$refs.searchRosterRef.hiden();
    },
    convertFullRosterSubmit(form) {
      updateInterviewer(form).then((response) => {
        if (response.success) {
          this.$message({
            message: '操作成功',
            type: 'success'
          })
          this.$refs.convertFullRosterRef.hiden()
          this.searchList('', this.getActivityStatus())
        }
      })
    },
    giveUpOfferSubmit(form) { // offer审批中的其他情况
      arrangeInterview(form).then((response) => {
        if (response.success) {
          this.$message({
            message: '操作成功',
            type: 'success'
          })
          this.$refs.table.hidenForm()
          this.searchList('', this.getActivityStatus())
        }
      })
    },
    interviewRosterSubmit(form) { // 安排面试
      arrangeInterview(form).then((response) => {
        if (response.success) {
          this.$message({
            message: '操作成功',
            type: 'success'
          })
          this.$refs.interviesEditRosterRef.hiden()
          this.searchList('', this.getActivityStatus())
        }
      })
    },
    eliminationRosterSubmit(form) { // 淘汰流失原因
      eliminate(form).then((response) => {
        if (response.success) {
          this.$message({
            message: '操作成功',
            type: 'success'
          })
          this.$refs.eliminationRosterRef.hiden()
          this.searchList('', this.getActivityStatus())
        }
      })
    },
    removeInterviewPassSubmit(form) { // 移动到面试通过
      // console.log(form)
      if (form.suggest === '1') { // 面试通过
        passInterviewer(form).then((response) => {
          if (response.success) {
            this.$message({
              message: '操作成功',
              type: 'success'
            })
            this.$refs.removeInterviewPassRosterRef.hiden()
            this.searchList('', this.getActivityStatus())
          }
        })
      }
      if (form.suggest === '2') { // 马上复试
        immediateInterviewer(form).then((response) => {
          if (response.success) {
            this.$message({
              message: '操作成功',
              type: 'success'
            })
            this.$refs.removeInterviewPassRosterRef.hiden()
            this.searchList('', this.getActivityStatus())
          }
        })
      }
      if (form.suggest === '3') { // 等待复试
        waitInterviewer(form).then((response) => {
          if (response.success) {
            this.$message({
              message: '操作成功',
              type: 'success'
            })
            this.$refs.removeInterviewPassRosterRef.hiden()
            this.searchList('', this.getActivityStatus())
          }
        })
      }
    },
    offerSendRosterSubmit(form) { // offer发送申请
      form.status = 6
      offerSendApply(form).then((response) => {
        if (response.success) {
          this.$message({
            message: '操作成功',
            type: 'success'
          })
          this.$refs.offerSendRosterRef.hiden()
          this.searchList('', this.getActivityStatus())
        }
      })
    },

    offerSendApproveSubmit(form) { // offer审批
      form.status = 7
      offerSendApply(form).then((response) => {
        if (response.success) {
          this.$message({
            message: '操作成功',
            type: 'success'
          })
          this.$refs.approveRef.hiden()
          this.searchList('', this.getActivityStatus())
        }
      })
    },
    sendOfferRosterSubmit(form) { // 发送offer、放弃
      arrangeInterview(form).then((response) => {
        if (response.success) {
          this.$message({
            message: '操作成功',
            type: 'success'
          })
          this.$refs.sendOfferRosterRef.hiden()
          this.searchList('', this.getActivityStatus())
        }
      })
    },


    moveingPrimaryPass(item) { // 移动到初选通过
      const params = {
        intvId: item.scope.row.intvId,
        status: 2
      }
      this.$confirm('移动到初选通过, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.updateInterviewerStatus(params)
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消操作'
        })
      })
    },

    moveingPrimary(item) { // 移动到候选人
      const params = {
        intvId: item.scope.row.intvId,
        status: 1
      }
      this.$confirm('移动到候选人, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.updateInterviewerStatus(params)
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消操作'
        })
      })
    },
    deleteItem(id) { // 删除
      deleteInterview(id).then((response) => {
        if (response.success) {
          this.$message({
            message: '删除成功!',
            type: 'success'
          })
          this.searchList('', this.getActivityStatus())
        }
      })
    },

    feedbackNoSubmit(form) { // 反馈不通过
      form.status = 'b'
      feedBackOffer(form).then((response) => {
        if (response.success) {
          this.$message({
            message: '操作成功!',
            type: 'success'
          })
          this.$refs.feedbackNoRef.hiden()
          this.$refs.feedbackYesRef.hiden()
          this.searchList()
        }
      })
    },

    feedbackYesSubmit(form) { // 反馈通过
      form.status = 'a'
      feedBackOffer(form).then((response) => {
        if (response.success) {
          this.$message({
            message: '操作成功!',
            type: 'success'
          })
          this.searchList('', this.getActivityStatus())

          this.$refs.feedbackNoRef.hiden()
          this.$refs.feedbackYesRef.hiden()
        }
      })
    },
    searchList() {
      const pageParams = this.searchParams
      pageParams.status = this.getActivityStatus()
      getRequireList(pageParams).then((response) => {
        this.waitVettData = response
        this.getTabs()
      })
    },

    getTabs() { // 获取状态以及对应的统计
      getPlanaudit().then((response) => {
        this.statusData = response.data
        this.tabs.primaryCount = response.data.count1
        this.tabs.primaryPassCount = response.data.count2
        this.tabs.interviewCount = response.data.count3
        this.tabs.interviewPassCount = response.data.count4
        this.tabs.offerApproveCount = response.data.count5
        this.tabs.offerRecuperativeCount = response.data.count6
      })
    },
    editSubmit(params, formType, formList) {
      // console.log(params, formType, formList)
      if (formType === 'add') {
        this.addItem(params)
      } else if (formType === 'search') {
        this.searchList(params, this.getActivityStatus())
      } else if (formType === 'delete') {
        const userId = params.row.intvId
        this.deleteItem(userId)
      } else if (formType === 'edit') {
        this.updataItem(params, params.intvId)
      }
    },
    updateInterviewerStatus(params) { // 状态变更
      updateStatus(params).then((response) => {
        if (response.success) {
          this.$message({
            message: '操作成功!',
            type: 'success'
          })

          this.searchList('', this.getActivityStatus())
        }
      })
    },

    findInterviewDetail(id, showCall) { // 详情
      findDetail(id).then((response) => {
        showCall(response.data)
      })
    },

    /**
     * 发送offer申请
     */
    findInterviewDetailOff(id, showCall) { // 详情
      findDetail(id).then((response) => {
        const baseData = {
          orgId: '',
          position: '',
          postLevel: ''
        }
        const obj = Object.assign(baseData, response.data)
        showCall(obj)
      })
    },


    findInterviewPassDetail(id, showCall) { // 移动到面试通过
      findProcessDetail(id).then((response) => {
        showCall(response.data)
      })
    },
    pageChange(pageObj) {
      this.searchParams.page = pageObj.page
      this.searchParams.pageSize = pageObj.pageSize
      this.searchList()
    },
    getActivityStatus() {
      if (this.activeName === 'candidate') {
        return 1;
      }
      if (this.activeName === 'primary') {
        return 2;
      }
      if (this.activeName === 'interview') {
        return 3;
      }
      if (this.activeName === 'interviewPass') {
        return 5;
      }
      if (this.activeName === 'offerApprove') {
        return 6;
      }
      if (this.activeName === 'offerFeedBack') {
        return 7;
      }
    },
    showSearch() {
      this.$refs.searchRosterRef.show()
    },
    showAdd() {
      this.$refs.addRosterRef.show()
    },
    quickSearch() { // 快捷搜索
      this.searchParams.page = 1
      this.searchParams.intvName = this.searchData
      this.searchList()
    },
    handleClick(tab, event) {
      this.searchParams.page = 1
      this.searchList('', tab.$attrs.status)
    }
  }
}
</script>

<style scoped>

</style>
